package Honor;

import java.util.Arrays;
import java.util.Scanner;

public class Main3 {
    static int maxn=100050;
    static int[] c=new int[maxn];
    static int[] num=new int[maxn];
    public static void update(int x,int y,int n){
        for (int i = x; i <= n; i+=(i&(-i))) {
            c[i]+=y;
        }
    }
    public static int getValue(int p){
        if (p==0){
            return 0;
        }
        int res=0;
        while (p!=0){
            res+=c[p];
            p-=(p&(-p));
        }
        return res;
    }
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int T=cin.nextInt();
        int MAXN=100004;
        for (int t = 0; t < T; t++) {
            int n=cin.nextInt();
            int max=-1,sum=0;
            for (int i = 0; i < n; i++) {
                Arrays.fill(c,0);
                Arrays.fill(num,0);
                int x=cin.nextInt();
                int t1=getValue(x-1);
                int t2=getValue(MAXN);
                t2-=num[x];
                int t3=t2-t1;
                sum+=(t1-t3);
                max=Math.max(max,sum);
                num[x]++;
                update(x,1,MAXN);
            }
            System.out.println(max+" "+sum);
        }
    }
}
